// Learn TypeScript:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html


import CustomButton from "../BASE/CButton";
import turn from "../game/time/turn";

import { Message } from "../Message/Message";
import MessageCenter from "../Message/MessageCenter";
import moveUI from "../UIS/BASEUI/moveUI";
import AnimalManager from "./AnimalManager";
import GeZiManager from "./GeZiManager";
import ManagerBase from "./ManagerBase";
import TNanager from "./TNanager";
import ZManager from "./ZManager";




const {ccclass, property} = cc._decorator;

@ccclass
export default class BUIManager extends ManagerBase {
  
   moveUI:cc.Node=null
    SUI:cc.Node=null;
     A1:cc.Node=null;
     A2:cc.Node=null;
     A3:cc.Node=null;
     A4:cc.Node=null;
     A5:cc.Node=null;
     leveUP:cc.Node=null;
     changL:cc.Node=null;
     SK1:cc.Node=null;
     SK2:cc.Node=null;
     SK3:cc.Node=null;
     JSK:cc.Node=null;
  start(){
    
      
  MessageCenter.addReceive(this)
 this.SUI= cc.find("Canvas/UIManager/shopUI/1L/A1")
 this.A1= cc.find("Canvas/UIManager/shopUI/1L/A1")
 this.A2= cc.find("Canvas/UIManager/shopUI/1L/A2")
 this.A3= cc.find("Canvas/UIManager/shopUI/1L/A3")
 this.A4= cc.find("Canvas/UIManager/shopUI/2L/XianJing")
 this.A5= cc.find("Canvas/UIManager/shopUI/2L/BCD")
 this.leveUP= cc.find("Canvas/UIManager/shopUI/3L/Leve")
 this.changL= cc.find("Canvas/UIManager/shopUI/3L/changL")
this. SK1=cc.find("Canvas/UIManager/BUI/CSkill/skill1")
this. SK2=cc.find("Canvas/UIManager/BUI/CSkill/skill2")
this. SK3=cc.find("Canvas/UIManager/BUI/CSkill/skill3")
this.JSK=cc.find("Canvas/UIManager/BUI/CSkill/JXskill")
this.moveUI=cc.find("Canvas/UIManager/BUIManager/BUI/BaseChoose/walk")

}
  
  
  
  
  
  
  
  ReceiveMessage(message: Message){

  if(message.Type=="BUI"){
  switch(message.Content){
  case"Ban":this.banUI(message.Command);
  break;
  case"Use":this.useUI(message.Command);
  break;
  case"change0.5":this.changeUI(message.Command,0.5);
  break;
  case"change1":this.changeUI(message.Command,1);
  break;
  }
  
  
  }    
  
  
  
  
  
  }
  
  
changeUI(number:number[],st:number){
    let  BUI=this.node.getChildByName("BUI")      
    let  BaseChoose=BUI.getChildByName("BaseChoose") 
    let  turnB=BUI.getChildByName("turnB")
   
let move=this.moveUI.getComponent(moveUI)

for(let n of number){
    switch (n) {
        
            case 1:switch (st) {
                case 0.5:move.torock(GeZiManager.PCP.faceTo);
                    
                    break;
            
                default:move.USE("walk")
                    break;
            }
           break
               
               
               
               
               
             
        }
        
        
            }



} 

  
useUI(number:number[]){
      
let move=this.moveUI.getComponent(moveUI)

    let  BUI=this.node.getChildByName("BUI")      
   let  BaseChoose=BUI.getChildByName("BaseChoose") 
  
   for(let n of number){
    switch (n) {
 
           case 0:move.USE("turn4");move.USE("turn6");
           break;
           case 1:move.USE("walk");
           break;
            case 2:BaseChoose.getChildByName("qi").getComponent(CustomButton).enableButton()
            break;
            case 3:BaseChoose.getChildByName("attack").getComponent(CustomButton).enableButton()
            break;
            case 4:BaseChoose.getChildByName("magic").getComponent(CustomButton).enableButton()
            break;
            case 5:BaseChoose.getChildByName("shop").getComponent(CustomButton).enableButton();BaseChoose.getChildByName("NWshop").getComponent(CustomButton).enableButton();
            break;
            case 51:this.A1.getComponent(CustomButton).enableButton()
            break;
            case 52:this.A2.getComponent(CustomButton).enableButton()
            break;
            case 53:this.A3.getComponent(CustomButton).enableButton()
            break;
            case 54:this.A4.getComponent(CustomButton).enableButton()
            break;
            case 55:this.A5.getComponent(CustomButton).enableButton()
            break;
            case 56:this.leveUP.getComponent(CustomButton).enableButton()
            break;
            case 57:this.changL.getComponent(CustomButton).enableButton()
            break;
           
        default:
            break;
    }
    
    
        }}
  
  
  
  
  ChangSkill(S:number){
switch (S) {
    case 1:this.SK1
        
        break;

    default:
        break;
}















  }
  
  
  
  banUI(number:number[]){
    let move=this.moveUI.getComponent(moveUI)
  let  BUI=this.node.getChildByName("BUI")      
 let  BaseChoose=BUI.getChildByName("BaseChoose")


  
 for(let n of number){
  switch (n) {

         case 0:move.BAN("turn4");move.BAN("turn6");
         break;
         case 0.5:move.BAN("推石头");
         break;
         case 1:move.BAN("walk");move.BAN("walk8");move.BAN("walk4");move.BAN("walk6");
         break;
         case 1.2:move.BAN("walk")
         break;
         case 1.4:move.BAN("walk4")
         break;
         case 1.6:move.BAN("walk6");
         break;
         case 1.8:move.BAN("walk8")
         break;
          case 2:BaseChoose.getChildByName("qi").getComponent(CustomButton).disableButton()
          break;
          case 3:BaseChoose.getChildByName("attack").getComponent(CustomButton).disableButton()
        
          break;
          case 4:BaseChoose.getChildByName("magic").getComponent(CustomButton).disableButton()
          break;
          case 5:BaseChoose.getChildByName("shop").getComponent(CustomButton).disableButton();BaseChoose.getChildByName("NWshop").getComponent(CustomButton).disableButton()
          break;
        
       
          case 51:this.A1.getComponent(cc.Button).getComponent(CustomButton).disableButton()
          break;
          case 52:this.A2.getComponent(cc.Button).getComponent(CustomButton).disableButton()
          break;
          case 53:this.A3.getComponent(cc.Button).getComponent(CustomButton).disableButton()
          break;
          case 54:this.A4.getComponent(cc.Button).getComponent(CustomButton).disableButton()
          break;
          case 55:this.A5.getComponent(cc.Button).getComponent(CustomButton).disableButton()
          break;
          case 56:this.leveUP.getComponent(cc.Button).getComponent(CustomButton).disableButton()
          break;
          case 57:this.changL.getComponent(cc.Button).getComponent(CustomButton).disableButton()
          break;
      default:
          break;
  }
}
  
      }
}
